<template>


    <div class="divLog">

      <el-form ref="login-form"  id="login-form" class="login-form">

        <h3>欢迎登录</h3>
            <el-form-item label="*用户名" >
              <el-input  placeholder="请输入用户名" v-model="forObject.username" ></el-input>
            </el-form-item>
            <el-form-item label="*密码" >
              <el-input placeholder="请输入密码" v-model="forObject.password" show-password></el-input>
            </el-form-item>
        <el-form-item >
                 <el-button type="primary" style="text-align: center;width: 100%"  @click="_login">登录</el-button>
          <p style="color: red;" >{{msg}}</p>
        </el-form-item>

      </el-form>
    </div>
</template>

<script>


    export default {
        name: "login",

        data(){
           return {
              forObject:{
                username:'',
                password:'',
              },
             msg:''


           }
        },

      methods: {
        _login(){
         let userData= this.forObject;
         this.$http.post("/login/login?username="+userData.username+'&password='+userData.password, userData).then(result=>{
            let returnData=result.data;
            if (0===returnData.code){
              this.$router.push({path:returnData.data,query:{}});
            } else{
              this.msg=returnData.message;
            }


         }).catch(err=>{


           console.log(err);
         })
        }
      }

    }



</script>

<style scoped>

  .loginDivClass{
    /*top: 100px;*/
    /*height: 100px;*/
    /*padding-top: 190px;*/
    /*padding-left: 500px;*/
    /*width: 300px;*/
    /*margin: auto;*/
    /*text-align:center;*/
    /*background-color: #3a8ee6;*/
  }
  .divLog{


  }

  .login-form{
    width: 350px;
    margin: 100px auto;
    border: 1px solid #DCDFE6;
    padding: 35px;
    border-radius: 5px;
    box-shadow: 0 0 25px #DCDFE6;
  }


</style>
